package wms2010.gui.views;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;

public class SimpleView extends JInternalFrame {
	protected JTable data;
	protected JPanel root = new JPanel();
	
	public SimpleView(AbstractTableModel tableModel) {
		this.init(tableModel, null, 1);
	}
	
	public SimpleView(AbstractTableModel tableModel, ListSelectionListener selectionModel, int rows) {
		this.init(tableModel, selectionModel, rows);
	}
	
	public SimpleView(AbstractTableModel tableModel, ListSelectionListener selectionModel) {
		this.init(tableModel, selectionModel,1);
	}
	
	public SimpleView() {
		
	}
	
	protected void init(AbstractTableModel tableModel, ListSelectionListener selectionModel, int rows) {
		this.data = new JTable(tableModel);
		this.data.getSelectionModel().addListSelectionListener(selectionModel);
		this.setBounds(25, 25, 600, 400);
		this.setResizable(true);
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		this.setClosable(true);
		this.setMaximizable(true);
		
		JScrollPane scrollPane = new JScrollPane(this.data);
		this.data.setFillsViewportHeight(true);
		
		this.root.setLayout(new GridLayout(rows, 1));
		this.root.add(scrollPane);
		this.add(root);	
	}
}
